﻿using System.Runtime.Serialization;
using BLToolkit.DataAccess;
using BLToolkit.Mapping;
using BLToolkit.Reflection;

namespace Calendar.Logic.ObjectModel
{
    public abstract class Entity// : EditableObject 
    {
        [DataMember, PrimaryKey(0), NonUpdatable, Identity]
        public abstract int ID { get; protected internal set; }

        //[DataMember, DisplayName(@"Описание")]
        //public abstract string DESC { get; set; }

        public virtual Entity CopyTo(Entity obj)
        {
            Map.ObjectToObject(this, obj);
            return obj;
        }

        public virtual Entity Clone()
        {
            var obj = (Entity)TypeAccessor.CreateInstanceEx(GetType());

            CopyTo(obj);
            //obj.AcceptChanges();

            return obj;
        }
    }
}
